package com.green.javagreen.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.green.javagreen.util.ReviewDateFormatUtl;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.sql.Timestamp;

/**
 * 用户实体父类,包含用户角色的基本参数和属性
 * 包括:1.登录时间
 * 2.是否禁用
 * 3.禁用时间
 * <p>
 * email:brioal@foxmail.com
 * github:https://github.com/Brioal
 * Created by brioa on 2019/2/23.
 */
@MappedSuperclass
@Setter
@Getter
public class BaseUserBean extends EntityBean {


    @ApiModelProperty(value = "用户名")
    private String name;

    @ApiModelProperty(value = "用户编号/账号")
    private String code;

    @ApiModelProperty(value = "登陆密码")
    private String passWord;

    @ApiModelProperty(value = "账号是否可用")
    @Column(columnDefinition = "tinyint default 1")
    private Boolean enable;

    @JsonIgnore
    @ApiModelProperty(value = "被禁用的时间")
    private Timestamp disabledTime;

    @Transient
    @ApiModelProperty(value = "用来传递的token")
    private String token;

    /**
     * 返回被禁用的时间
     *
     * @return
     */
    public String getDisabledTimeStr() {
        return ReviewDateFormatUtl.formatFullDate(disabledTime);
    }
}
